Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix @plugin scoping rules #2522

Merged
merged 6 commits into from
Apr 1, 2015
Merged

Conversation

rjgotten
Copy link
Contributor

This pull request fixes remaining scoping issues with the @plugin mechanic that #2479 introduced.

  • @plugin inside a directive block is now in scope for descendants of the directive block.
  • Mixins now properly inherit functions from definition scope. This was mistakingly using the caller scope.
  • Updated the unit tests for @plugin to cover scope inheritance and shadowing cases.

Fixed scope for plugins to apply correctly for mixins, directives and
detached rulesets.
Updated plugin unit tests to be more comprehensive
functionRegistry was mistakingly inheriting from the top frame of the
caller context, which was incorrect. It should inherit from definition
scope.
@rjgotten rjgotten changed the title Fix plugin scoping rules Fix @plugin scoping rules Mar 23, 2015
@rjgotten rjgotten mentioned this pull request Mar 23, 2015
@@ -0,0 +1,11 @@
#ns {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this file checked in by mistake?

@rjgotten
Copy link
Contributor Author

was this file checked in by mistake?

Oops. Yes. I thought I flagged that one as 'do not commit'. Maybe the GitHub client glitched.

@rjgotten
Copy link
Contributor Author

There we go. Deleted and ammended.

@@ -144,7 +145,16 @@ ImportVisitor.prototype = {
}
},
visitRule: function (ruleNode, visitArgs) {
visitArgs.visitDeeper = false;
if (ruleNode.value.type === "DetachedRuleset") {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import and plugin directives inside detached rulesets didn't work as expected because the visitor was stopping at the rule level, never entering the detached ruleset declaration.

This change enables it for the simple form of @var : { ... } and verifies that scoping for plugin works as expected in that scenario. You may want to not take this particular change. Just notifying and trying to be clear.

lukeapage added a commit that referenced this pull request Apr 1, 2015
@lukeapage lukeapage merged commit 86fa4f6 into less:master Apr 1, 2015
@rjgotten rjgotten deleted the fix-plugin-scoping branch April 24, 2015 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants